<script type="text/javascript">
onerror = handleError; 

function handleError(msg, url, line){
	var message = "本页存在错误。\n";
	message += "错误：" + msg + "\n";
	message += "URL：" + url + "\n"; 
	message += "行号：" + line + "\n"; 
	message += "点击确定继续";
	return true; 
}
var searchMode = 1; 

$(document).ready(function(){
$("#errorSearch").hide(); 
$("#infoView").hide();
$("#aboutView").hide();
$("#mysubmit").hide();
$("#clearall").hide(); 

$("#orgTab").click(function(){
	$("#aboutView").hide();
	$("#infoView").hide();
	$("#errorSearch").hide("normal"); 
	$("#clearall").click();
	searchMode = 1; 
}); 

$("#errorTab").click(function(){
	$("#aboutView").hide();
	$("#infoView").hide();
	$("#errorSearch").show("normal"); 
	$("#clearall").click();
	searchMode = 2; 
});

$("#infoTab").click(function(){
	$("#infoView").hide();
	$("#errorSearch").hide(); 
	$("#aboutView").hide();
	$("#clearall").click();
	$("#infoView").show("normal");
});

$("#keywords").keydown(function(event){
	if (event.which == 13) {
		$("#submit").click(); 
		$("#keywords").focus(); 
	}
});

$("#uid").keydown(function(event){
	if (event.which == 13) {
		$("#submit").click(); 
		$("#keywords").focus(); 
	}
});

$("#aboutTab").click(function(){
	$("#infoView").hide();
	$("#errorSearch").hide(); 
	$("#aboutView").hide();
	$("#clearall").click();
	$("#aboutView").show("normal");
});

$("#submit").mouseover(function(){
	$("#submit")[0].src = "__PUBLIC__/images/search_glow.jpg";
}); 

$("#submit").mouseout(function(){
	$("#submit")[0].src = "__PUBLIC__/images/search.jpg";
}); 

$("#dlbutton").mouseover(function(){
	$("#dlbutton")[0].src = "__PUBLIC__/images/download_glow.jpg";
}); 

$("#dlbutton").mouseout(function(){
	$("#dlbutton")[0].src = "__PUBLIC__/images/download.jpg";
}); 

$(".submit").click(function(){
	var dl = 0; 
	if (this.id == "dlbutton") {
		dl = 1;
		//alert("下载");
		$("#resultList").html("&nbsp;&nbsp;&nbsp;系统正在为您生成Excel文件...请您耐心等待..."); 
	} else {
		//alert("搜索");
		$("#resultList").html("&nbsp;&nbsp;&nbsp;系统正在为您检索中...请您耐心等待..."); 
	}
	$('#download')[0].value = dl; 
	var kw = $('#keywords')[0].value;
	var lkw = $('#lastkeywords')[0].value;
	var sc = $('#school')[0].value; 
	var gd = $('#gender')[0].value; 
	var tmin = $('#studytime')[0].value; 
	var tmax = parseInt(tmin) + 150; 

	var fl = $('#firstlang')[0].value; 
	var yr = $('#year')[0].value; 
	var ud = $('#uid')[0].value;  
	var er = $('#error')[0].value; 
	var sp = $('#samepage')[0].value; 
	if (sp == 1) pg = $('#page')[0].value; else {
		pg = 1; 
		$('#page')[0].value = 1; 
	}	
	$('#lastkeywords')[0].value = kw; 
	var ln = $('#listnum')[0].value;
		
	if (dl == 0){
		if (searchMode == 1){
			if (tmin == 0){
				$("#resultList").load("__URL__/search" , { keywords: kw, school: sc, gender: gd, firstlang:fl, year:yr, uid:ud, page:pg, listnum:ln, download:dl} );
			} else {
				$("#resultList").load("__URL__/search" , { keywords: kw, school: sc, gender: gd, timemin: tmin, timemax: tmax, firstlang:fl, year:yr, uid:ud, page:pg, listnum:ln, download:dl} );
			}
		} else { 
			if (tmin == 0){
				$("#resultList").load("__URL__/search" , { keywords: kw, school: sc, gender: gd, firstlang:fl, year:yr, uid:ud, error:er, page:pg, listnum:ln, download:dl} );
			} else {
				$("#resultList").load("__URL__/search" , { keywords: kw, school: sc, gender: gd, timemin: tmin, timemax: tmax, firstlang:fl, year:yr, uid:ud, error:er, page:pg, listnum:ln, download:dl} );
			}
		}
	} else {
			//$("#myForm").submit();
			//alert("已经提交");
		$("#mysubmit").click();
		//if (searchMode == 1){
		//	$.ajax({ type: "POST", url: "__URL__/search", data:  { keywords: kw, school: sc, gender: gd, studytime: st, firstlang:fl, year:yr, uid:ud, page:pg, listnum:ln, download:dl},  success: function(str_response) {  var obj = window.open("about:blank");  obj.document.write(str_response);  } });  
		//} else { 
		//	$.ajax({  type: "POST", url: "__URL__/search",  data: { keywords: kw, school: sc, gender: gd, studytime: st, firstlang:fl, year:yr, uid:ud, error:er, page:pg, listnum:ln, download:dl},  success: function(str_response) {  var obj = window.open("about:blank");  obj.document.write(str_response);  }  });  
		//}
	}
	$('#samepage')[0].value = 0; 
	if (this.id == "dlbutton ") {
		$("#resultList").html("&nbsp;&nbsp;&nbsp;系统已经为您生成了Excel文件，请到您的下载目录中查看。"); 
	} 
}); 
}); 
</script>

<div id="search" align="center">
<div class="wrapper">
<div id="header" class="row b-l">
	<div id="logo">
		<a href="{:U("Search/index")}">Corpus</a>
	</div>
	<div class="column grid_1">&nbsp; </div>		
	<ul class="tabs">
		<li class="first"><a href="#tab1" id="orgTab">原文检索</a></li>
		<li><a href="#tab2" id="errorTab">错误检索</a></li>
		<li><a href="#tab3" id="infoTab">语料库信息</a></li>
		<li><a href="#tab4" id="aboutTab">关于</a></li>
	</ul>
</div>
</div>

<div id="form">
<form name="myForm" id="myForm" target="_blank" action="__URL__/search" method="post">
<div class="row">
	<div id="searchBox">
		<div class="column grid_7"><input type="text" id="keywords" name="keywords" style="height:23px;width:95%" class="large bLeft" value="{$keywords}"/> </div>
	</div>
	<div class="column gird_2"><td class="tRight" width="16%"><img class="submit" id="submit" src="__PUBLIC__/images/search.jpg"/> </div>
	<div class="column gird_2"><td class="tRight" width="16%"><img class="submit" id="dlbutton" src="__PUBLIC__/images/download.jpg"/> </div>
</div>
 
<div class="row" id="errorSearch">
	<br/>
	<div class="column grid_1"> 错误检索： </div>			
	<div class="column grid_2">
		<select id="baseError" style="width:130px">
			<option value="所有类型">不限</option>
			<option value="书写错误">书写错误</option>
			<option value="词语错误">词语错误</option>
			<option value="词组错误">词组错误</option>
			<option value="句子错误">句子错误</option>
			<option value="文章格式">文章格式</option>
		</select> 
	</div>
 
	<div class="column grid_1">  </div>			
	<div class="column grid_2">
		<select id="nextError" class="sError" style="width:130px">
			<option value="">不限</option>
		</select>
	</div>
	
	<div class="column grid_1">  </div>			
	<div class="column grid_2">
		<select id="tempError" class="sError" style="width:130px">
			<option value="">不限</option>
		</select>
	</div>
	
	<div class="column grid_1">  </div>			
	<div class="column grid_2">
		<select id="realError" class="sError" style="width:130px">
			<option value="">不限</option>
		</select>
	</div>
</div>

<div class="row" id="infoView">
{$newsInfo.content}
</div>

<div class="row" id="aboutView">
{$newsAbout.content}
</div>
 
<div id="seperate" class="row b-l"></div>
<div class="row">
	<div class="column grid_1">作者学校： </div>			
	<div class="column grid_2">
		<select id="school" name="school" style="width:130px">
			<option value="">不限</option>
			<option value="j">j</option>
			<option value="d">d</option>
			<option value="s">s</option>
			<option value="w">w</option>
			<option value="n">n</option>
		</select>
	</div>

	<div class="column grid_1">作者性别： </div>			
	<div class="column grid_2">
		<select id="gender" name="gender" style="width:130px">
			<option value="">不限</option>
			<option value="男">男</option>
			<option value="女">女</option>
		</select>
	</div>
	
	<div class="column grid_1">学习时间： </div>			
	<div class="column grid_2">
		<select id="studytime" name="studytime" style="width:132px">
			<option value="0">不限</option>
			<option value="700">700-850</option>
			<option value="850">850-900</option>
			<option value="1000">1000-1150</option>
			<option value="1150">1150-1300</option>
			<option value="1300">1300-1450</option>
			<option value="1450">1450-1600</option>
			<option value="1600">1600-1750</option>
			<option value="1750">1750-1900</option>
			<option value="1900">1900-2050</option>
			<option value="2050">2050-2200</option>
			<option value="2200">2200-2350</option>
		</select>
	</div>
	
	<div class="column grid_1">学生母语： </div>			
	<div class="column grid_2">
		<select id="firstlang" name="firstlang" style="width:130px">
			<option value="">不限</option>
			<option value="中国語">中国语</option>
			<option value="朝鮮語">朝鲜语</option>
			<option value="モンゴル語">蒙古语</option>
			<option value="英語">英语</option>
		</select>
	</div>
	
	<div class="column grid_1">写作学期：</div>			
	<div class="column grid_2">
		<select id="year" name="year" style="width:130px">
			<option value="">不限</option>
			<option value="x3">x3</option>
			<option value="x4">x4</option>
			<option value="x5">x5</option>
			<option value="x6">x6</option>
			<option value="x7">x7</option>
			<option value="x8">x8</option>
		</select>
	</div>
	
	<div class="column grid_1">作者代码：</div>			
	<div class="column grid_2">
		<input type="text" id="uid" name="uid" style="width:130px" class="large bLeft">
	</div>
</div>
<div class="row">
	<div class="page column grid_1">每页条目：</div>
	<div class="column grid_2">
		<input type="number" value="30" id="listnum" name="listnum" style="width:130px" class="large bLeft" min="3" max="90"/>
		<input id="error" name="error" type="hidden" value=""/>
		<input id="page" name="page" type="hidden" value="1"/>
		<input id="samepage" name="samepage" type="hidden" value="1"/>
		<input id="editword" type="hidden" value="1"/>
		<input id="download" name="download" type="hidden" value="1"/>
		<input id="lastkeywords" type="hidden" value="corpus"/>
	</div>
	
	<div class="column grid_3">
		<input type="submit" id="mysubmit" value="输出excel文件（utf8转gb2312）"/>
		<input type="reset" id="clearall"/>
	</div>
</div>

<div id="seperate" class="row b-l"></div>
</form>
</div>
</div>

</div>
</div>
</div>

<div class="row main" id="resultList">
</div>
<div id="downloadList">
</div>